package com.czl.base.data.bean.tengyun

import java.io.Serializable

data class AssetHandleBean(
    val handleApplicationId: Int? = null,
    val applicationNo: String? = null,
    var applicationName: String? = null,
    var applicationCompanyId: Int? = null,
    var applicationUserId: String? = null,
    val applicationUserName: String? = null,
    val handleApplicationName: String? = null,
    var parentCompanyShortName: String? = null,
    val handleTypeName: String? = null,
    val status: Int? = null,
    val statusName: String? = null,
    val handleApplicationTime: String? = null,
    var parentCompanyName: String? = null,
    var facilityType: Int? = null,
    var parentCompanyId: Int? = null,
    var applicationOrganizationId: Int? = null,
    var applicationOrganizationName: String? = null,
    var note: String? = null,
//    val lowerList: List<LowerListBean>? = null,
    var inUseLowerList: MutableList<AssetHandleSortBean>? = null,
    var inStroreLowerList: MutableList<AssetHandleSortBean>? = null,
    var inUseProductList: MutableList<AssetHandleSortBean>? = null,
    var inStroreProductList: MutableList<AssetHandleSortBean>? = null,
    var facilityList: List<AssetHandleFacilityBean>? = null,
    var handleType: Int? = 1,
    var type: Int? = 1,
    var checkInfo: Boolean = false,
    var isCancel: Boolean = false,
    var file: List<FileBean>? = null,
    var applicationIdFileList: List<FileBean>? = null
) : Serializable {
    fun getFacilityTypeStr(): String {
        if (facilityType != null) {
            return FacilityTypeList[facilityType!!]
        }
        return ""
    }

    fun getStatusStr(): String {
        if (status != null) {
            return StatusList[status!!]
        }
        return ""
    }

    fun getFacilityListSize(): Int {
        if (facilityList != null) {
            return facilityList!!.size
        }
        return 0
    }

    fun getLowerList(): MutableList<LowerListBean> {
        val list: MutableList<LowerListBean> = arrayListOf()
        if (inUseLowerList != null && !inUseLowerList!!.isEmpty()) {
            val lowerListBean = LowerListBean()
            lowerListBean.sortList = inUseLowerList!!
            var assetCount: Int = 0
            for (bean in inUseLowerList!!) {
                assetCount += bean.assetCount!!
            }
            lowerListBean.note = "在用低耗品（" + assetCount + "）"
            lowerListBean.manageMode = 0
            lowerListBean.inuse = 1
            list.add(lowerListBean)
        }
        if (inStroreLowerList != null && !inStroreLowerList!!.isEmpty()) {
            val lowerListBean = LowerListBean()
            lowerListBean.sortList = inStroreLowerList!!
            var assetCount: Int = 0
            for (bean in inStroreLowerList!!) {
                assetCount += bean.assetCount!!
            }
            lowerListBean.note = "库存物品（" + assetCount + "）"
            lowerListBean.manageMode = 0
            lowerListBean.inuse = 0
            list.add(lowerListBean)
        }
        if (inUseProductList != null && !inUseProductList!!.isEmpty()) {
            val lowerListBean = LowerListBean()
            lowerListBean.sortList = inUseProductList!!
            lowerListBean.note = "在用单品（" + inUseProductList!!.size + "）"
            lowerListBean.manageMode = 1
            lowerListBean.inuse = 1
            list.add(lowerListBean)
        }
        if (inStroreProductList != null && !inStroreProductList!!.isEmpty()) {
            val lowerListBean = LowerListBean()
            lowerListBean.sortList = inStroreProductList!!
            lowerListBean.note = "库存单品（" + inStroreProductList!!.size + "）"
            lowerListBean.manageMode = 1
            lowerListBean.inuse = 0
            list.add(lowerListBean)
        }
        return list
    }

}

var StatusList = arrayListOf<String>("草稿", "待审核", "审批通过", "审批驳回", "撤回")

var FacilityTypeList = arrayListOf<String>("固定资产处置", "低耗品处置")

class LowerListBean(
    var note: String = "",
    var manageMode: Int = 0,
    var inuse: Int = 0,
    var sortList: MutableList<AssetHandleSortBean> = arrayListOf()
) : Serializable